<template>
  <view class="container">
    <!-- 状态栏 -->
    <view class="status-bar">
      <text class="status-time">9:41</text>
      <view class="status-right">
        <view class="signal-bars">
          <view class="bar bar1"></view>
          <view class="bar bar2"></view>
          <view class="bar bar3"></view>
        </view>
        <view class="wifi-icon">📶</view>
        <view class="battery-container">
          <view class="battery-body">
            <view class="battery-fill"></view>
          </view>
          <view class="battery-tip"></view>
        </view>
      </view>
    </view>

    <!-- 顶部头部区域 -->
    <view class="header">
      <view class="header-left">
        <image class="logo" src="/static/logo.png" mode="aspectFit"></image>
        <view class="header-text">
          <text class="main-title">KITCHENER-WATERLOO CHINESE</text>
          <text class="sub-title">STUDENTS & SCHOLARS ASSOCIATION</text>
          <text class="chinese-title">滑铁卢-基奇纳中国学生学者联谊会</text>
        </view>
      </view>
      <view class="header-right">
        <view class="menu-icon">
          <view class="dot"></view>
          <view class="dot"></view>
          <view class="dot"></view>
        </view>
        <view class="settings-icon">
          <view class="settings-circle">
            ⚙
          </view>
        </view>
      </view>
    </view>

    <!-- 3D BANNER轮播区域 -->
    <view class="banner-section">
      <swiper class="banner-swiper" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="500"
        @change="onBannerChange">
        <swiper-item v-for="(banner, index) in banners" :key="index">
          <view class="banner-container">
            <image class="banner-image" :src="banner.image" mode="aspectFill"></image>
            <view class="banner-overlay">
              <text class="banner-text">{{ banner.title }}</text>
            </view>
          </view>
        </swiper-item>
      </swiper>
      <!-- 自定义指示器 -->
      <view class="custom-indicators">
        <view v-for="(banner, index) in banners" :key="index" class="indicator-line"
          :class="{ 'active': currentBannerIndex === index }"></view>
      </view>
    </view>

    <!-- 功能卡片区域 -->
    <view class="service-cards">
      <view class="service-card rideshare-card" @tap="navigateTo('rideshare')">
        <image src="/static/home/6.png" mode="aspectFill"></image>
      </view>
      <view class="service-card housing-card" @tap="navigateTo('housing')">
        <view class="card-content">
          <image src="/static/home/7.png" mode="aspectFill"></image>
        </view>
      </view>
    </view>

    <!-- 精选活动推荐 -->
    <view class="section">
      <view class="section-header">
        <view class="section-title">
          <!-- <text class="folder-icon">📁</text> -->
          <image src="/static/home/5.png" class="section-title-image" mode="aspectFill"></image>
          <text class="title-text">精选活动推荐</text>
        </view>
        <view class="more-link">
          <text>查看更多</text>
          <!-- <text class="arrow">></text> -->
          <image src="/static/home/right.png" class="arrow" mode="aspectFill"></image>
        </view>
      </view>

      <view class="activity-card" @tap="navigateTo('activity')">
        <image class="activity-image" src="/static/home/a1.png" mode="aspectFill"></image>
        <view class="activity-content">
          <text class="activity-title">KUMAMONLI脚足球夏令营开幕</text>
          <view class="activity-info">
            <!-- <text class="info-icon">📅</text> -->
            <image src="/static/home/9.png" class="info-icon" mode="aspectFill"></image>
            <text class="info-text">活动时间：08/10-08/20</text>
            <view class="register-btn">
              立即报名
            </view>
          </view>
        </view>
      </view>
    </view>

    <!-- 热门帖子 -->
    <view class="section">
      <view class="section-header">
        <view class="section-title">
          <!-- <text class="fire-icon">🔥</text> -->
          <image src="/static/home/4.png" class="section-title-image" mode="aspectFill"></image>
          <text class="title-text">热门帖子</text>
        </view>
        <view class="more-link">
          <text>查看更多</text>
          <!-- <text class="arrow">></text> -->
          <image src="/static/home/right.png" class="arrow" mode="aspectFill"></image>
        </view>
      </view>

      <!-- 帖子列表 -->
      <view class="post-list">
        <view class="post-item" v-for="(post, index) in posts" :key="index" @tap="navigateTo('post', post.id)">
          <view class="post-avatar">
            <image class="avatar-image" :src="post.avatar" mode="aspectFill"></image>
            <view class="post-header">
              <text class="post-author">{{ post.author }}</text>
              <view class="post-tag">
                <text class="tag-text">{{ post.school }}</text>
              </view>
            </view>
          </view>
          <view class="post-content">
           
            <text class="post-text">{{ post.content }}</text>
            <image v-if="post.image" class="post-image" :src="post.image" mode="aspectFill"></image>
            <view class="post-footer">
              <text class="post-time">{{ post.time }}</text>
              <view class="post-actions">
                <view class="action-item">
                  <!-- <text class="like-icon">👍</text> -->
                  <image src="/static/home/zan.png" class="like-icon" mode="aspectFill"></image>
                  <text class="action-count">{{ post.likes }}</text>
                </view>
                <view class="action-item">
                  <!-- <text class="comment-icon">💬</text> -->
                  <image src="/static/home/pinglun.png" class="comment-icon" mode="aspectFill"></image>
                  <text class="action-count">{{ post.comments }}</text>
                </view>
                <view class="action-item">
                  <!-- <text class="share-icon">⚙</text> -->
                  <image src="/static/home/yanjing.png" class="share-icon" mode="aspectFill"></image>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>

     <!-- 底部导航栏 -->
     <BottomNav current-page="home" />
  </view>
</template>

<script>
import BottomNav from '../../components/BottomNav.vue'

export default {
  components: {
    BottomNav
  },
  data() {
    return {
      currentBannerIndex: 0,
      banners: [
        {
          id: 1,
          title: 'BANNER',
          image: '/static/banner-bg.jpg'
        },
        {
          id: 2,
          title: 'BANNER',
          image: '/static/banner-bg2.jpg'
        },
        {
          id: 3,
          title: 'BANNER',
          image: '/static/banner-bg3.jpg'
        }
      ],
      posts: [
        {
          id: 1,
          author: '谢小盛',
          school: 'University of Waterloo',
          avatar: '/static/home/av.png',
          content: '苍穹之上，雄鹰是不朽的王者，它身披黑褐色羽衣，羽翼舒展时似巨大的风帆，划破流云，身...',
          image: '/static/home/a1.png',
          time: '10/21',
          likes: 70,
          comments: 48
        },
        {
          id: 2,
          author: '韩春',
          school: 'University of Waterloo',
          avatar: '/static/home/av.png',
          content: '苍穹之上，雄鹰是不朽的王者，它身披黑褐色羽衣，羽翼舒展时似巨大的风帆，划破流云，身...',
          image: '/static/home/a1.png',
          time: '2025/10/20 12:24',
          likes: 70,
          comments: 48
        }
      ]
    }
  },
  onLoad() {
    // 设置状态栏样式
    uni.setNavigationBarTitle({
      title: ''
    });
  },
   methods: {
     onBannerChange(event) {
       this.currentBannerIndex = event.detail.current;
     },
    navigateTo(type, id) {
      // 导航逻辑
      console.log('Navigate to:', type, id);
      
      if (type === 'rideshare') {
        uni.navigateTo({
          url: '/pages/rideshare/rideshare'
        });
      } else if (type === 'housing') {
        console.log('Housing page not implemented yet');
      } else if (type === 'activity') {
        console.log('Activity page not implemented yet');
      } else if (type === 'post') {
        console.log('Post detail page not implemented yet, post id:', id);
      }
    }
   }
}
</script>

<style scoped>
.container {
  min-height: 100vh;
  background: #f8f9fa;
  padding-bottom: 120rpx;
  /* 为底部导航留空间 */
}

/* 状态栏 */
.status-bar {
  height: 88rpx;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30rpx;
  font-size: 28rpx;
  font-weight: 600;
}

.status-time {
  color: #333;
}

.status-right {
  display: flex;
  align-items: center;
}

.signal-bars {
  display: flex;
  align-items: flex-end;
  margin-right: 12rpx;
}

.bar {
  width: 6rpx;
  background: #333;
  margin-right: 2rpx;
  border-radius: 1rpx;
}

.bar1 {
  height: 8rpx;
}

.bar2 {
  height: 12rpx;
}

.bar3 {
  height: 16rpx;
}

.wifi-icon {
  font-size: 24rpx;
  margin-right: 12rpx;
}

.battery-container {
  display: flex;
  align-items: center;
}

.battery-body {
  width: 48rpx;
  height: 24rpx;
  border: 2rpx solid #333;
  border-radius: 4rpx;
  position: relative;
  background: #fff;
}

.battery-fill {
  position: absolute;
  left: 2rpx;
  top: 2rpx;
  width: 36rpx;
  height: 16rpx;
  background: #34c759;
  border-radius: 2rpx;
}

.battery-tip {
  width: 4rpx;
  height: 12rpx;
  background: #333;
  border-radius: 0 2rpx 2rpx 0;
  margin-left: 2rpx;
}

/* 头部区域 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30rpx 30rpx 20rpx 30rpx;
  background: #fff;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo {
  width: 60rpx;
  height: 60rpx;
  margin-right: 20rpx;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.main-title {
  font-size: 24rpx;
  font-weight: bold;
  color: #333;
  line-height: 1.2;
}

.sub-title {
  font-size: 24rpx;
  font-weight: bold;
  color: #333;
  line-height: 1.2;
}

.chinese-title {
  font-size: 22rpx;
  color: #666;
  margin-top: 8rpx;
}

.header-right {
  display: flex;
  align-items: center;
}

.menu-icon {
  display: flex;
  flex-direction: column;
  margin-right: 30rpx;
}

.dot {
  width: 8rpx;
  height: 8rpx;
  background: #333;
  border-radius: 50%;
  margin: 2rpx 0;
}

.settings-icon {
  margin-left: 20rpx;
}

.settings-circle {
  width: 60rpx;
  height: 60rpx;
  background: #f0f0f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
  color: #666;
}

/* BANNER轮播区域 */
.banner-section {
  margin: 20rpx 30rpx;
  position: relative;
}

.banner-swiper {
  height: 360rpx;
  border-radius: 20rpx;
  overflow: hidden;
}

.banner-container {
  position: relative;
  height: 100%;
  border-radius: 20rpx;
  overflow: hidden;
  background: linear-gradient(135deg, #4a5568 0%, #2d3748 50%, #1a202c 100%);
  box-shadow:
    inset 0 1px 3px rgba(255, 255, 255, 0.1),
    0 10rpx 30rpx rgba(0, 0, 0, 0.3);
}

.banner-image {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.banner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.banner-text {
  font-size: 64rpx;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.5),
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 3px 0 rgba(0, 0, 0, 0.3),
    0 4px 0 rgba(0, 0, 0, 0.2),
    0 5px 0 rgba(0, 0, 0, 0.1),
    0 6px 10rpx rgba(0, 0, 0, 0.4);
  letter-spacing: 4rpx;
}

/* 自定义指示器样式 */
.custom-indicators {
  position: absolute;
  bottom: 30rpx;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16rpx;
  z-index: 20;
}

.indicator-line {
  transition: all 0.3s ease;
  width: 8rpx;
  height: 8rpx;
  opacity: 1;
  border-radius: 8rpx;
  background: rgba(255, 214, 46, 0.5);
}

.indicator-line.active {
  background: #ffd700;
  width: 24rpx;
  height: 8rpx;
  background: rgba(255, 195, 0, 1);
}

/* 服务卡片 */
.service-cards {
  display: flex;
  justify-content: space-between;
  padding: 0 15rpx;
  margin: 30rpx 0;
}

.service-card {
  flex: 1;
  height: 198rpx;
  border-radius: 16rpx;
  margin: 0 15rpx;
  /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08); */
  overflow: hidden;
  position: relative;

  image {
    width: 100%;
    height: 100%;
  }
}

.rideshare-card {
  background: linear-gradient(135deg, #fff8dc 0%, #f5deb3 100%);
}

.housing-card {
  background: linear-gradient(135deg, #fff8dc 0%, #f5deb3 100%);
}

.card-content {
  height: 100%;
  display: flex;
  /* flex-direction: column; */
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.card-icon-wrapper {
  margin-bottom: 20rpx;
}

/* 汽车图标样式 */
.car-icon {
  position: relative;
  width: 80rpx;
  height: 50rpx;
}

.car-body {
  position: absolute;
  width: 70rpx;
  height: 30rpx;
  background: #ffd700;
  border-radius: 15rpx 15rpx 8rpx 8rpx;
  top: 8rpx;
  left: 5rpx;
  box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.2);
}

.car-window {
  position: absolute;
  width: 50rpx;
  height: 15rpx;
  background: #87ceeb;
  border-radius: 8rpx;
  top: 12rpx;
  left: 15rpx;
}

.car-wheel {
  position: absolute;
  width: 16rpx;
  height: 16rpx;
  background: #333;
  border-radius: 50%;
  bottom: 2rpx;
}

.wheel-left {
  left: 8rpx;
}

.wheel-right {
  right: 8rpx;
}

/* 建筑图标样式 */
.building-icon {
  position: relative;
  width: 60rpx;
  height: 70rpx;
}

.building-base {
  position: absolute;
  width: 60rpx;
  height: 50rpx;
  background: #4169e1;
  bottom: 0;
  border-radius: 4rpx 4rpx 0 0;
  box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.2);
}

.building-floors {
  position: absolute;
  width: 50rpx;
  height: 40rpx;
  left: 5rpx;
  bottom: 5rpx;
}

.floor {
  width: 100%;
  height: 8rpx;
  background: rgba(255, 255, 255, 0.3);
  margin-bottom: 2rpx;
  border-radius: 1rpx;
}

.building-top {
  position: absolute;
  width: 20rpx;
  height: 20rpx;
  background: #ffd700;
  top: 0;
  left: 20rpx;
  border-radius: 4rpx;
}

.card-title {
  font-size: 28rpx;
  color: #333;
  font-weight: 600;
}

/* 通用区域样式 */
.section {
  margin: 40rpx 30rpx;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.section-title {
  display: flex;
  align-items: center;

  .section-title-image {
    width: 48rpx;
    height: 48rpx;
    margin-right: 16rpx;
  }
}

.folder-icon,
.fire-icon {
  font-size: 32rpx;
  margin-right: 16rpx;
}

.title-text {
  font-size: 32rpx;
  font-weight: 600;
  color: #333;
}

.more-link {
  display: flex;
  align-items: center;
  color: #666;
  font-size: 28rpx;
  line-height: 31rpx;

  image {
    width: 32rpx;
    height: 32rpx;
  }
}

.arrow {
  margin-left: 8rpx;
}

/* 活动卡片 */
.activity-card {
  background: #fff;
  border-radius: 20rpx;
  overflow: hidden;
  /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08); */
}

.activity-image {
  width: 100%;
  height: 260rpx;
}

.activity-content {
  padding: 30rpx;
}

.activity-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333;
  margin-bottom: 20rpx;
}

.activity-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.info-icon {
  margin-right: 12rpx;
  width: 32rpx;
  height: 32rpx;
}

.info-text {
  font-size: 26rpx;
  color: #666;
  flex: 1;
}

.register-btn {
  background: #ffd700;
  padding: 12rpx 30rpx;
  border-radius: 50rpx;
  font-size: 24rpx;
  color: #333;
  font-weight: 500;
}


/* 帖子列表 */
.post-list {
  /* background: #fff; */
  
  overflow: hidden;
}

.post-item {
  /* display: flex; */
  padding: 30rpx;
  background: #fff;
  margin-bottom: 30rpx;
  border-radius: 20rpx;
  /* border-bottom: 1rpx solid #f0f0f0; */
}

/* .post-item:last-child {
  border-bottom: none;
} */

.post-avatar {
  margin-right: 20rpx;
  display: flex;
  align-items: center;
  margin-bottom: 16rpx;
  /* justify-content: space-between; */
}

.avatar-image {
  width: 80rpx;
  height: 80rpx;
  border-radius: 50%;
}

.post-content {
  flex: 1;
}

.post-header {
  margin-left: 20rpx;
  display: flex;
  flex-direction: column;
  /* align-items: center; */
  /* margin-bottom: 16rpx; */
  justify-content: space-between;
}

.post-author {
  font-size: 28rpx;
  font-weight: 600;
  color: #333;
  margin-right: 20rpx;
}

.post-tag {
  height: 40rpx;
  border-radius: 1000rpx;

  border: 2rpx solid #999999;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4rpx 16rpx 4rpx 16rpx;
}

.tag-text {
  font-size: 24rpx;
  color: #666;
}

.post-text {
  font-size: 26rpx;
  color: #333;
  line-height: 1.6;
  margin-bottom: 20rpx;
}

.post-image {
  width: 100%;
  height: 200rpx;
  border-radius: 12rpx;
  margin: 20rpx 0;
}

.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20rpx;
  border-top: 1rpx solid #f0f0f0;
}

.post-time {
  font-size: 24rpx;
  color: #999;
}

.post-actions {
  display: flex;
  align-items: center;
}

.action-item {
  display: flex;
  align-items: center;
  margin-left: 30rpx;
}

.like-icon,
.comment-icon,
.share-icon {
  width: 32rpx;
  height: 32rpx;
  margin-right: 8rpx;
}

.action-count {
  font-size: 28rpx;
  font-weight: 400;
  color: #000;
}

</style>
